package com.sharding.demo.config;

import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingValue;
import org.springframework.stereotype.Component;

import java.util.Collection;
import java.util.List;
import java.util.Properties;

/**
 * @Author hu xu hong
 * @Date 2023/1/18 16:04
 * ShardingSphere 用户类hit分片式路由算法
 */
//@Component
@Slf4j
public class UserCloudHintShardingAlgorithm implements HintShardingAlgorithm<String> {

    public UserCloudHintShardingAlgorithm(){
    }


    List<String> tcloudIds = Lists.newArrayList();

    /**
     *
     * @param availableTargetNames 数据源列表
     * @param shardingValue  数据源分片值
     * @return
     */
    @Override
    public Collection<String> doSharding(Collection<String> availableTargetNames, HintShardingValue<String> shardingValue) {
        List<String> result = Lists.newArrayList();
        result.add("sharding0");
        return result;
    }


    @Override
    public Properties getProps() {
        return null;
    }

    @Override
    public void init(Properties properties) {

    }
}
